<template>
  <div>
    <!-- Breadcrumb 面包屑 导航区-->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">权限管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- Card 卡片 卡片视图区-->
    <el-card class="box-card">
      <!-- 表格区-->
      <el-table :data="rightList" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column label="等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level == '0'">一级</el-tag>
            <el-tag v-if="scope.row.level === '1'" type="success">二级</el-tag>
            <el-tag v-if="scope.row.level === '2'" type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      // 权限列表
      rightList: null
    }
  },
  methods: {
    // 优化异步操作 async await
    async getRightlist () {
      const { data: res } = await this.$http.get('rights/' + 'list')
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error('获取数据失败')
      this.rightList = res.data
    }
  },
  created () {
    this.getRightlist()
  }
}
</script>
<style lang="less" scoped></style>
